home *** CD-ROM | disk | FTP | other *** search
- Path: uunet!snorkelwacker!apple!netcom!amdcad!sun!mipsdal.mips.com
- From: riley@mipsdal.mips.com (Riley Rainey)
- Newsgroups: comp.sources.x
- Subject: v09i070: acm, X aerial combat simulation, Part02/05
- Message-ID: <143449@sun.Eng.Sun.COM>
- Date: 7 Oct 90 18:12:55 GMT
- References: <csx-09i069:acm@uunet.UU.NET>
- Sender: news@sun.Eng.Sun.COM
- Lines: 2395
- Approved: argv@sun.com
-
- Submitted-by: riley@mipsdal.mips.com (Riley Rainey)
- Posting-number: Volume 9, Issue 70
- Archive-name: acm/part02
-
- echo x - ./V/test/f16
- sed 's/^X//' >./V/test/f16 <<'*-*-END-of-./V/test/f16-*-*'
- XF-16-fighter
- X130 12
- X1 -18.165 0 0
- X2 -18.165 -1.191 0
- X3 -15.187 -2.085 0
- X4 -13.698 -2.382 0
- X5 -17.272 -2.382 0
- X6 -17.272 -3.573 0
- X7 -10.923 -3.573 0
- X8 -4.169 -3.573 0
- X9 -4.169 -4.765 0
- X10 5.598 -4.765 0
- X11 18.463 -2.144 0
- X12 18.939 -1.787 0
- X13 22.274 -1.489 0
- X14 24.895 -1.191 0
- X15 27.992 0 0
- X16 -6.551 -3.573 0
- X17 -6.551 -15.485 0
- X18 0.357 -15.485 0
- X19 0.357 -15.187 0
- X20 -2.978 -15.008 0
- X21 5.598 -4.765 0
- X22 -4.169 -4.765 0
- X23 -4.169 -3.573 0
- X24 -17.272 -3.573 0
- X25 -17.272 -8.934 0.893
- X26 -15.187 -8.934 0.893
- X27 -10.923 -3.573 0
- X28 27.992 0 0
- X29 24.895 1.191 0
- X30 22.274 1.489 0
- X31 18.939 1.787 0
- X32 18.463 2.144 0
- X33 5.598 4.765 0
- X34 -4.169 4.765 0
- X35 -4.169 3.573 0
- X36 -10.923 3.573 0
- X37 -17.272 3.573 0
- X38 -17.272 2.382 0
- X39 -13.698 2.382 0
- X40 -15.187 2.085 0
- X41 -18.165 1.191 0
- X42 -18.165 0 0
- X43 5.598 4.765 0
- X44 -2.978 15.008 0
- X45 0.357 15.187 0
- X46 0.357 15.485 0
- X47 -6.551 15.485 0
- X48 -6.551 3.573 0
- X49 -4.169 3.573 0
- X50 -4.169 4.765 0
- X51 -10.923 3.573 0
- X52 -15.187 8.934 0.893
- X53 -17.272 8.934 0.893
- X54 -17.272 3.573 0
- X55 27.992 0 0
- X56 23.525 0 -1.191
- X57 17.272 0 -2.382
- X58 15.783 0 -3.812
- X59 13.996 0 -4.169
- X60 11.316 0 -4.05
- X61 8.338 0 -3.335
- X62 1.787 0 -2.382
- X63 -4.169 0 -2.382
- X64 -13.936 0 -1.906
- X65 -15.128 0 -1.906
- X66 -15.187 0 -1.787
- X67 -18.165 0 -1.191
- X68 -18.165 0 0
- X69 -4.169 0 -2.382
- X70 -10.125 0 -4.05
- X71 -15.783 0 -10.482
- X72 -19.654 0 -10.482
- X73 -19.654 0 -9.529
- X74 -19.654 0 -9.529
- X75 -16.378 0 -3.573
- X76 -16.378 0 -2.144
- X77 -14.889 0 -2.382
- X78 -13.936 0 -2.382
- X79 -13.936 0 -1.906
- X80 -18.165 0 0
- X81 -18.165 0 1.191
- X82 -15.187 0 2.085
- X83 -13.698 0 2.263
- X84 -2.68 0 2.382
- X85 8.04 0 2.382
- X86 12.507 0 2.263
- X87 12.507 0 0.596
- X88 19.952 0 0.596
- X89 23.525 0 0.476
- X90 27.992 0 0
- X91 -3.551 0 -2.382
- X92 -3.551 -3.871 -0.10
- X93 -3.551 -15.485 0
- X94 -3.551 -15.485 0.1065
- X95 -3.551 -3.871 0.142
- X96 -3.551 -2.58 0.2556
- X97 -3.551 -2.387 1.818
- X98 -3.551 -2.102 2.015
- X99 -3.551 -1.03 2.251
- X100 -3.551 0 2.282
- X101 -3.551 1.03 2.251
- X102 -3.551 2.102 2.015
- X103 -3.551 2.387 1.818
- X104 -3.551 2.58 0.2556
- X105 -3.551 3.871 0.142
- X106 -3.551 15.485 0.1065
- X107 -3.551 15.485 0
- X108 -3.551 3.871 -0.10
- X109 13.996 0 -4.169
- X110 13.996 -0.8932 -3.692
- X111 13.996 -1.191 -2.978
- X112 13.996 -1.251 -2.502
- X113 13.996 -1.787 -1.311
- X114 13.996 -3.054 0
- X115 13.996 -1.583 0.3568
- X116 13.996 0 0.596
- X117 13.996 1.583 0.3568
- X118 13.996 3.054 0
- X119 13.996 1.787 -1.311
- X120 13.996 1.251 -2.502
- X121 13.996 1.191 -2.978
- X122 13.996 0.8932 -3.692
- X123 -18.165 1.191 0
- X124 -18.165 0.842 0.842
- X125 -18.165 0 1.191
- X126 -18.165 -0.842 0.842
- X127 -18.165 -1.191 0
- X128 -18.165 -0.842 -0.842
- X129 -18.165 0 -1.191
- X130 -18.165 0.842 -0.842
- Xgray33 14 109 110 111 112 113 114 115 116 117 118 119 120 121 122
- Xgray33 18 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
- Xgray33 15 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
- Xgray33 8 16 17 18 19 20 21 22 23
- Xgray33 4 24 25 26 27
- Xgray33 15 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
- Xgray33 8 43 44 45 46 47 48 49 50
- Xgray33 4 51 52 53 54
- Xgray33 14 55 56 57 58 59 60 61 62 63 64 65 66 67 68
- Xgray33 11 69 70 71 72 73 74 75 76 77 78 79
- Xgray33 11 80 81 82 83 84 85 86 87 88 89 90
- Xgray33 8 123 124 125 126 127 128 129 130
- *-*-END-of-./V/test/f16-*-*
- echo x - ./V/test/Makefile
- sed 's/^X//' >./V/test/Makefile <<'*-*-END-of-./V/test/Makefile-*-*'
- X# Makefile for V library test programs
- X#
- X# Riley Rainey; riley@10hnl1.ceo.dg.com
- X#
- X# This makefile can be used to create a demonstration program
- X# for the V library. This program, named animate, uses the V library
- X# and X color palette manipulation to create an animated flying scene.
- XOBJFILES = animate.o app.o
- XCFLAGS = -g
- X
- Xanimate: $(OBJFILES)
- X cc -g -o animate $(OBJFILES) -L/usr/lib/X11 -L../lib -lV -lX11 -lm -lbsd
- X
- Xclean:
- X rm *.o core
- X
- Xclobber:
- X rm *.o animate
- *-*-END-of-./V/test/Makefile-*-*
- echo x - ./V/test/fixf16.c
- sed 's/^X//' >./V/test/fixf16.c <<'*-*-END-of-./V/test/fixf16.c-*-*'
- X#include "../lib/Vlib.h"
- X
- Xmain () {
- X
- X int i, k;
- X VObject *obj;
- X VPolygon **poly;
- X VPoint *q, tmp;
- X VMatrix mtx;
- X
- X if ((obj = VReadObject(stdin)) == (VObject *) NULL) {
- X fprintf (stderr, "Error reading the object definition.\n");
- X exit (1);
- X }
- X
- X/*
- X * Prepare a transformation matrix that:
- X * (a) swaps X and Y coordinates.
- X * (b) negates Z coordinate.
- X */
- X
- X VIdentMatrix (&mtx);
- X mtx.m[0][0] = 0.0;
- X mtx.m[0][1] = 1.0;
- X mtx.m[1][0] = 1.0;
- X mtx.m[1][1] = 0.0;
- X mtx.m[2][2] = -1.0;
- X
- X poly = obj->polygon;
- X
- X for (i=0; i<obj->numPolys; ++i) {
- X for ((k=0, q=poly[i]->vertex); k<poly[i]->numVtces; (++k, ++q)) {
- X VTransform(q, &mtx, &tmp);
- X *q = tmp;
- X }
- X }
- X
- X VWriteObject (stdout, obj);
- X}
- *-*-END-of-./V/test/fixf16.c-*-*
- echo x - ./V/test/f
- sed 's/^X//' >./V/test/f <<'*-*-END-of-./V/test/f-*-*'
- XF-16-fighter
- X90 9
- X1 -18.165 0 0
- X2 -18.165 -1.191 0
- X3 -15.187 -2.085 0
- X4 -13.698 -2.382 0
- X5 -17.272 -2.382 0
- X6 -17.272 -3.573 0
- X7 -10.923 -3.573 0
- X8 -4.169 -3.573 0
- X9 -4.169 -4.765 0
- X10 5.598 -4.765 0
- X11 18.463 -2.144 0
- X12 18.939 -1.787 0
- X13 22.274 -1.489 0
- X14 24.895 -1.191 0
- X15 27.992 0 0
- X16 -6.551 -3.573 0
- X17 -6.551 -15.485 0
- X18 0.357 -15.485 0
- X19 0.357 -15.187 0
- X20 -2.978 -15.008 0
- X21 5.598 -4.765 0
- X22 -4.169 -4.765 0
- X23 -4.169 -3.573 0
- X24 -17.272 -3.573 0
- X25 -17.272 -8.934 0.893
- X26 -15.187 -8.934 0.893
- X27 -10.923 -3.573 0
- X28 27.992 0 0
- X29 24.895 1.191 0
- X30 22.274 1.489 0
- X31 18.939 1.787 0
- X32 18.463 2.144 0
- X33 5.598 4.765 0
- X34 -4.169 4.765 0
- X35 -4.169 3.573 0
- X36 -10.923 3.573 0
- X37 -17.272 3.573 0
- X38 -17.272 2.382 0
- X39 -13.698 2.382 0
- X40 -15.187 2.085 0
- X41 -18.165 1.191 0
- X42 -18.165 0 0
- X43 5.598 4.765 0
- X44 -2.978 15.008 0
- X45 0.357 15.187 0
- X46 0.357 15.485 0
- X47 -6.551 15.485 0
- X48 -6.551 3.573 0
- X49 -4.169 3.573 0
- X50 -4.169 4.765 0
- X51 -10.923 3.573 0
- X52 -15.187 8.934 0.893
- X53 -17.272 8.934 0.893
- X54 -17.272 3.573 0
- X55 27.992 0 0
- X56 23.525 0 -1.191
- X57 17.272 0 -2.382
- X58 15.783 0 -3.812
- X59 13.996 0 -4.169
- X60 11.316 0 -4.05
- X61 8.338 0 -3.335
- X62 1.787 0 -2.382
- X63 -4.169 0 -2.382
- X64 -13.936 0 -1.906
- X65 -15.128 0 -1.906
- X66 -15.187 0 -1.787
- X67 -18.165 0 -1.191
- X68 -18.165 0 0
- X69 -4.169 0 -2.382
- X70 -10.125 0 -4.05
- X71 -15.783 0 -10.482
- X72 -19.654 0 -10.482
- X73 -19.654 0 -9.529
- X74 -19.654 0 -9.529
- X75 -16.378 0 -3.573
- X76 -16.378 0 -2.144
- X77 -14.889 0 -2.382
- X78 -13.936 0 -2.382
- X79 -13.936 0 -1.906
- X80 -18.165 0 0
- X81 -18.165 0 1.191
- X82 -15.187 0 2.085
- X83 -13.698 0 2.263
- X84 -2.68 0 2.382
- X85 8.04 0 2.382
- X86 12.507 0 2.263
- X87 12.507 0 0.596
- X88 19.952 0 0.596
- X89 23.525 0 0.476
- X90 27.992 0 0
- Xgray 15 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
- Xgray 8 16 17 18 19 20 21 22 23
- Xgray 4 24 25 26 27
- Xgray 15 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
- Xgray 8 43 44 45 46 47 48 49 50
- Xgray 4 51 52 53 54
- Xgray 14 55 56 57 58 59 60 61 62 63 64 65 66 67 68
- Xgray 11 69 70 71 72 73 74 75 76 77 78 79
- Xgray 11 80 81 82 83 84 85 86 87 88 89 90
- *-*-END-of-./V/test/f-*-*
- echo x - ./V/test/mig23
- sed 's/^X//' >./V/test/mig23 <<'*-*-END-of-./V/test/mig23-*-*'
- Xmig-23-wings-swept
- X88 10
- X1 36.5891 0 0
- X2 34.4368 0.86092 0
- X3 30.9931 1.29138 0
- X4 27.119 1.72184 0
- X5 20.6621 1.72184 0
- X6 18.9402 2.1523 0
- X7 14.2052 3.01322 0
- X8 -3.44368 2.58276 0
- X9 -9.03966 2.1523 0
- X10 -16.7879 0.86092 0
- X11 -18.0793 0.43046 0
- X12 -18.0793 0 0
- X13 36.5891 0 0
- X14 34.4368 -0.86092 0
- X15 30.9931 -1.29138 0
- X16 27.119 -1.72184 0
- X17 20.6621 -1.72184 0
- X18 18.9402 -2.1523 0
- X19 14.2052 -3.01322 0
- X20 -3.44368 -2.58276 0
- X21 -9.03966 -2.1523 0
- X22 -16.7879 -0.86092 0
- X23 -18.0793 -0.43046 0
- X24 -18.0793 0 0
- X25 14.2052 3.01322 -3.01322
- X26 4.73506 7.31782 -3.01322
- X27 6.02644 8.6092 -3.01322
- X28 -11.192 13.7747 -3.01322
- X29 -12.0529 13.7747 -3.01322
- X30 -14.2052 11.192 -3.01322
- X31 -14.2052 10.7615 -3.01322
- X32 -3.44368 2.58276 -3.01322
- X33 14.2052 -3.01322 -3.01322
- X34 4.73506 -7.31782 -3.01322
- X35 6.02644 -8.6092 -3.01322
- X36 -11.192 -13.7747 -3.01322
- X37 -12.0529 -13.7747 -3.01322
- X38 -14.2052 -11.192 -3.01322
- X39 -14.2052 -10.7615 -3.01322
- X40 -3.44368 -2.58276 -3.01322
- X41 -18.9402 3.01322 -1.72184
- X42 -20.2316 7.31782 -1.72184
- X43 -18.5098 8.6092 -1.72184
- X44 -9.03966 2.1523 -1.72184
- X45 -16.7879 0.86092 -1.72184
- X46 -18.9402 -3.01322 -1.72184
- X47 -20.2316 -7.31782 -1.72184
- X48 -18.5098 -8.6092 -1.72184
- X49 -9.03966 -2.1523 -1.72184
- X50 -16.7879 -0.86092 -1.72184
- X51 36.5891 0 0
- X52 33.1454 0 -1.29138
- X53 30.1322 0 -2.1523
- X54 25.8276 0 -2.58276
- X55 22.3839 0 -3.87414
- X56 18.0793 0 -4.3046
- X57 9.47012 0 -3.87414
- X58 -0.860918 0 -3.44368
- X59 -8.6092 0 -6.02644
- X60 -16.3575 0 -10.331
- X61 -18.9402 0 -9.03966
- X62 -18.0793 0 -3.87414
- X63 -19.8012 0 -3.44368
- X64 -17.2184 0 -1.72184
- X65 -18.0793 0 -1.72184
- X66 -18.0793 0 1.29138
- X67 -15.4966 0 1.72184
- X68 -6.4569 0 2.1523
- X69 10.331 0 2.1523
- X70 20.2316 0 1.72184
- X71 28.8408 0 1.29138
- X72 33.1454 0 0.86092
- X73 -15.4966 0 1.72184
- X74 -15.4966 0 4.3046
- X75 -13.3443 0 5.16552
- X76 -6.4569 0 2.1523
- X77 20.6621 1.72184 -3.01322
- X78 18.9402 2.1523 -3.01322
- X79 14.2052 3.01322 -3.01322
- X80 -3.44368 2.58276 -3.01322
- X81 -3.44368 -2.58276 -3.01322
- X82 14.2052 -3.01322 -3.01322
- X83 18.9402 -2.1523 -3.01322
- X84 20.6621 -1.72184 -3.01322
- X85 -3.44368 2.58276 -3.01322
- X86 -16.7879 0.86092 -1.72184
- X87 -16.7879 -0.86092 -1.72184
- X88 -3.44368 -2.58276 -3.01322
- Xgray 12 1 2 3 4 5 6 7 8 9 10 11 12
- Xgray 12 13 14 15 16 17 18 19 20 21 22 23 24
- Xgray 8 25 26 27 28 29 30 31 32
- Xgray 8 33 34 35 36 37 38 39 40
- Xgray 5 41 42 43 44 45
- Xgray 5 46 47 48 49 50
- Xgray 22 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
- Xgray 4 73 74 75 76
- Xgray 8 77 78 79 80 81 82 83 84
- Xgray 4 85 86 87 88
- *-*-END-of-./V/test/mig23-*-*
- echo x - ./V/test/fixmig.c
- sed 's/^X//' >./V/test/fixmig.c <<'*-*-END-of-./V/test/fixmig.c-*-*'
- X#include "../lib/Vlib.h"
- X
- Xmain () {
- X
- X int i, k;
- X VObject *obj;
- X VPolygon **poly;
- X VPoint *q, tmp;
- X VMatrix mtx;
- X
- X if ((obj = VReadObject(stdin)) == (VObject *) NULL) {
- X fprintf (stderr, "Error reading the object definition.\n");
- X exit (1);
- X }
- X
- X/*
- X * Prepare a transformation matrix that:
- X * (a) swaps X and Y coordinates.
- X * (b) negates Z coordinate.
- X */
- X
- X VIdentMatrix (&mtx);
- X mtx.m[0][3] = 39.60232;
- X mtx.m[0][0] = -2.1523;
- X mtx.m[1][1] = 2.1523;
- X mtx.m[2][2] = 2.1523;
- X
- X poly = obj->polygon;
- X
- X for (i=0; i<obj->numPolys; ++i) {
- X for ((k=0, q=poly[i]->vertex); k<poly[i]->numVtces; (++k, ++q)) {
- X VTransform(q, &mtx, &tmp);
- X *q = tmp;
- X }
- X }
- X
- X VWriteObject (stdout, obj);
- X}
- *-*-END-of-./V/test/fixmig.c-*-*
- echo x - ./V/test/fullrwy
- sed 's/^X//' >./V/test/fullrwy <<'*-*-END-of-./V/test/fullrwy-*-*'
- XRunway
- X280 69
- X1 0.000000 -75.000000 0.000000
- X2 12000.000000 -75.000000 0.000000
- X3 12000.000000 75.000000 0.000000
- X4 0.000000 75.000000 0.000000
- X5 0.000000 -75.000000 0.000000
- X6 12000.000000 -75.000000 0.000000
- X7 12000.000000 -70.000000 0.000000
- X8 0.000000 -70.000000 0.000000
- X9 0.000000 75.000000 0.000000
- X10 12000.000000 75.000000 0.000000
- X11 12000.000000 70.000000 0.000000
- X12 0.000000 70.000000 0.000000
- X13 1000.000000 -66.000000 0.000000
- X14 1125.000000 -66.000000 0.000000
- X15 1125.000000 -36.000000 0.000000
- X16 1000.000000 -36.000000 0.000000
- X17 1000.000000 66.000000 0.000000
- X18 1125.000000 66.000000 0.000000
- X19 1125.000000 36.000000 0.000000
- X20 1000.000000 36.000000 0.000000
- X21 11000.000000 -66.000000 0.000000
- X22 10875.000000 -66.000000 0.000000
- X23 10875.000000 -36.000000 0.000000
- X24 11000.000000 -36.000000 0.000000
- X25 11000.000000 66.000000 0.000000
- X26 10875.000000 66.000000 0.000000
- X27 10875.000000 36.000000 0.000000
- X28 11000.000000 36.000000 0.000000
- X29 4.000000 -66.000000 0.000000
- X30 129.000000 -66.000000 0.000000
- X31 129.000000 -54.888889 0.000000
- X32 4.000000 -54.888889 0.000000
- X33 4.000000 -50.888889 0.000000
- X34 129.000000 -50.888889 0.000000
- X35 129.000000 -39.777779 0.000000
- X36 4.000000 -39.777779 0.000000
- X37 4.000000 -35.777779 0.000000
- X38 129.000000 -35.777779 0.000000
- X39 129.000000 -24.666666 0.000000
- X40 4.000000 -24.666666 0.000000
- X41 4.000000 -20.666666 0.000000
- X42 129.000000 -20.666666 0.000000
- X43 129.000000 -9.555555 0.000000
- X44 4.000000 -9.555555 0.000000
- X45 4.000000 9.555555 0.000000
- X46 129.000000 9.555555 0.000000
- X47 129.000000 20.666666 0.000000
- X48 4.000000 20.666666 0.000000
- X49 4.000000 24.666666 0.000000
- X50 129.000000 24.666666 0.000000
- X51 129.000000 35.777779 0.000000
- X52 4.000000 35.777779 0.000000
- X53 4.000000 39.777779 0.000000
- X54 129.000000 39.777779 0.000000
- X55 129.000000 50.888889 0.000000
- X56 4.000000 50.888889 0.000000
- X57 4.000000 54.888889 0.000000
- X58 129.000000 54.888889 0.000000
- X59 129.000000 66.000000 0.000000
- X60 4.000000 66.000000 0.000000
- X61 11996.000000 -66.000000 0.000000
- X62 11871.000000 -66.000000 0.000000
- X63 11871.000000 -54.888889 0.000000
- X64 11996.000000 -54.888889 0.000000
- X65 11996.000000 -50.888889 0.000000
- X66 11871.000000 -50.888889 0.000000
- X67 11871.000000 -39.777779 0.000000
- X68 11996.000000 -39.777779 0.000000
- X69 11996.000000 -35.777779 0.000000
- X70 11871.000000 -35.777779 0.000000
- X71 11871.000000 -24.666666 0.000000
- X72 11996.000000 -24.666666 0.000000
- X73 11996.000000 -20.666666 0.000000
- X74 11871.000000 -20.666666 0.000000
- X75 11871.000000 -9.555555 0.000000
- X76 11996.000000 -9.555555 0.000000
- X77 11996.000000 9.555555 0.000000
- X78 11871.000000 9.555555 0.000000
- X79 11871.000000 20.666666 0.000000
- X80 11996.000000 20.666666 0.000000
- X81 11996.000000 24.666666 0.000000
- X82 11871.000000 24.666666 0.000000
- X83 11871.000000 35.777779 0.000000
- X84 11996.000000 35.777779 0.000000
- X85 11996.000000 39.777779 0.000000
- X86 11871.000000 39.777779 0.000000
- X87 11871.000000 50.888889 0.000000
- X88 11996.000000 50.888889 0.000000
- X89 11996.000000 54.888889 0.000000
- X90 11871.000000 54.888889 0.000000
- X91 11871.000000 66.000000 0.000000
- X92 11996.000000 66.000000 0.000000
- X93 258.000000 -2.500000 0.000000
- X94 383.000000 -2.500000 0.000000
- X95 383.000000 2.500000 0.000000
- X96 258.000000 2.500000 0.000000
- X97 508.000000 -2.500000 0.000000
- X98 633.000000 -2.500000 0.000000
- X99 633.000000 2.500000 0.000000
- X100 508.000000 2.500000 0.000000
- X101 758.000000 -2.500000 0.000000
- X102 883.000000 -2.500000 0.000000
- X103 883.000000 2.500000 0.000000
- X104 758.000000 2.500000 0.000000
- X105 1008.000000 -2.500000 0.000000
- X106 1133.000000 -2.500000 0.000000
- X107 1133.000000 2.500000 0.000000
- X108 1008.000000 2.500000 0.000000
- X109 1258.000000 -2.500000 0.000000
- X110 1383.000000 -2.500000 0.000000
- X111 1383.000000 2.500000 0.000000
- X112 1258.000000 2.500000 0.000000
- X113 1508.000000 -2.500000 0.000000
- X114 1633.000000 -2.500000 0.000000
- X115 1633.000000 2.500000 0.000000
- X116 1508.000000 2.500000 0.000000
- X117 1758.000000 -2.500000 0.000000
- X118 1883.000000 -2.500000 0.000000
- X119 1883.000000 2.500000 0.000000
- X120 1758.000000 2.500000 0.000000
- X121 2008.000000 -2.500000 0.000000
- X122 2133.000000 -2.500000 0.000000
- X123 2133.000000 2.500000 0.000000
- X124 2008.000000 2.500000 0.000000
- X125 2258.000000 -2.500000 0.000000
- X126 2383.000000 -2.500000 0.000000
- X127 2383.000000 2.500000 0.000000
- X128 2258.000000 2.500000 0.000000
- X129 2508.000000 -2.500000 0.000000
- X130 2633.000000 -2.500000 0.000000
- X131 2633.000000 2.500000 0.000000
- X132 2508.000000 2.500000 0.000000
- X133 2758.000000 -2.500000 0.000000
- X134 2883.000000 -2.500000 0.000000
- X135 2883.000000 2.500000 0.000000
- X136 2758.000000 2.500000 0.000000
- X137 3008.000000 -2.500000 0.000000
- X138 3133.000000 -2.500000 0.000000
- X139 3133.000000 2.500000 0.000000
- X140 3008.000000 2.500000 0.000000
- X141 3258.000000 -2.500000 0.000000
- X142 3383.000000 -2.500000 0.000000
- X143 3383.000000 2.500000 0.000000
- X144 3258.000000 2.500000 0.000000
- X145 3508.000000 -2.500000 0.000000
- X146 3633.000000 -2.500000 0.000000
- X147 3633.000000 2.500000 0.000000
- X148 3508.000000 2.500000 0.000000
- X149 3758.000000 -2.500000 0.000000
- X150 3883.000000 -2.500000 0.000000
- X151 3883.000000 2.500000 0.000000
- X152 3758.000000 2.500000 0.000000
- X153 4008.000000 -2.500000 0.000000
- X154 4133.000000 -2.500000 0.000000
- X155 4133.000000 2.500000 0.000000
- X156 4008.000000 2.500000 0.000000
- X157 4258.000000 -2.500000 0.000000
- X158 4383.000000 -2.500000 0.000000
- X159 4383.000000 2.500000 0.000000
- X160 4258.000000 2.500000 0.000000
- X161 4508.000000 -2.500000 0.000000
- X162 4633.000000 -2.500000 0.000000
- X163 4633.000000 2.500000 0.000000
- X164 4508.000000 2.500000 0.000000
- X165 4758.000000 -2.500000 0.000000
- X166 4883.000000 -2.500000 0.000000
- X167 4883.000000 2.500000 0.000000
- X168 4758.000000 2.500000 0.000000
- X169 5008.000000 -2.500000 0.000000
- X170 5133.000000 -2.500000 0.000000
- X171 5133.000000 2.500000 0.000000
- X172 5008.000000 2.500000 0.000000
- X173 5258.000000 -2.500000 0.000000
- X174 5383.000000 -2.500000 0.000000
- X175 5383.000000 2.500000 0.000000
- X176 5258.000000 2.500000 0.000000
- X177 5508.000000 -2.500000 0.000000
- X178 5633.000000 -2.500000 0.000000
- X179 5633.000000 2.500000 0.000000
- X180 5508.000000 2.500000 0.000000
- X181 5758.000000 -2.500000 0.000000
- X182 5883.000000 -2.500000 0.000000
- X183 5883.000000 2.500000 0.000000
- X184 5758.000000 2.500000 0.000000
- X185 6008.000000 -2.500000 0.000000
- X186 6133.000000 -2.500000 0.000000
- X187 6133.000000 2.500000 0.000000
- X188 6008.000000 2.500000 0.000000
- X189 6258.000000 -2.500000 0.000000
- X190 6383.000000 -2.500000 0.000000
- X191 6383.000000 2.500000 0.000000
- X192 6258.000000 2.500000 0.000000
- X193 6508.000000 -2.500000 0.000000
- X194 6633.000000 -2.500000 0.000000
- X195 6633.000000 2.500000 0.000000
- X196 6508.000000 2.500000 0.000000
- X197 6758.000000 -2.500000 0.000000
- X198 6883.000000 -2.500000 0.000000
- X199 6883.000000 2.500000 0.000000
- X200 6758.000000 2.500000 0.000000
- X201 7008.000000 -2.500000 0.000000
- X202 7133.000000 -2.500000 0.000000
- X203 7133.000000 2.500000 0.000000
- X204 7008.000000 2.500000 0.000000
- X205 7258.000000 -2.500000 0.000000
- X206 7383.000000 -2.500000 0.000000
- X207 7383.000000 2.500000 0.000000
- X208 7258.000000 2.500000 0.000000
- X209 7508.000000 -2.500000 0.000000
- X210 7633.000000 -2.500000 0.000000
- X211 7633.000000 2.500000 0.000000
- X212 7508.000000 2.500000 0.000000
- X213 7758.000000 -2.500000 0.000000
- X214 7883.000000 -2.500000 0.000000
- X215 7883.000000 2.500000 0.000000
- X216 7758.000000 2.500000 0.000000
- X217 8008.000000 -2.500000 0.000000
- X218 8133.000000 -2.500000 0.000000
- X219 8133.000000 2.500000 0.000000
- X220 8008.000000 2.500000 0.000000
- X221 8258.000000 -2.500000 0.000000
- X222 8383.000000 -2.500000 0.000000
- X223 8383.000000 2.500000 0.000000
- X224 8258.000000 2.500000 0.000000
- X225 8508.000000 -2.500000 0.000000
- X226 8633.000000 -2.500000 0.000000
- X227 8633.000000 2.500000 0.000000
- X228 8508.000000 2.500000 0.000000
- X229 8758.000000 -2.500000 0.000000
- X230 8883.000000 -2.500000 0.000000
- X231 8883.000000 2.500000 0.000000
- X232 8758.000000 2.500000 0.000000
- X233 9008.000000 -2.500000 0.000000
- X234 9133.000000 -2.500000 0.000000
- X235 9133.000000 2.500000 0.000000
- X236 9008.000000 2.500000 0.000000
- X237 9258.000000 -2.500000 0.000000
- X238 9383.000000 -2.500000 0.000000
- X239 9383.000000 2.500000 0.000000
- X240 9258.000000 2.500000 0.000000
- X241 9508.000000 -2.500000 0.000000
- X242 9633.000000 -2.500000 0.000000
- X243 9633.000000 2.500000 0.000000
- X244 9508.000000 2.500000 0.000000
- X245 9758.000000 -2.500000 0.000000
- X246 9883.000000 -2.500000 0.000000
- X247 9883.000000 2.500000 0.000000
- X248 9758.000000 2.500000 0.000000
- X249 10008.000000 -2.500000 0.000000
- X250 10133.000000 -2.500000 0.000000
- X251 10133.000000 2.500000 0.000000
- X252 10008.000000 2.500000 0.000000
- X253 10258.000000 -2.500000 0.000000
- X254 10383.000000 -2.500000 0.000000
- X255 10383.000000 2.500000 0.000000
- X256 10258.000000 2.500000 0.000000
- X257 10508.000000 -2.500000 0.000000
- X258 10633.000000 -2.500000 0.000000
- X259 10633.000000 2.500000 0.000000
- X260 10508.000000 2.500000 0.000000
- X261 10758.000000 -2.500000 0.000000
- X262 10883.000000 -2.500000 0.000000
- X263 10883.000000 2.500000 0.000000
- X264 10758.000000 2.500000 0.000000
- X265 11008.000000 -2.500000 0.000000
- X266 11133.000000 -2.500000 0.000000
- X267 11133.000000 2.500000 0.000000
- X268 11008.000000 2.500000 0.000000
- X269 11258.000000 -2.500000 0.000000
- X270 11383.000000 -2.500000 0.000000
- X271 11383.000000 2.500000 0.000000
- X272 11258.000000 2.500000 0.000000
- X273 11508.000000 -2.500000 0.000000
- X274 11633.000000 -2.500000 0.000000
- X275 11633.000000 2.500000 0.000000
- X276 11508.000000 2.500000 0.000000
- X277 11758.000000 -2.500000 0.000000
- X278 11883.000000 -2.500000 0.000000
- X279 11883.000000 2.500000 0.000000
- X280 11758.000000 2.500000 0.000000
- Xblack 4 1 2 3 4
- Xwhite 4 5 6 7 8
- Xwhite 4 9 10 11 12
- Xwhite 4 13 14 15 16
- Xwhite 4 17 18 19 20
- Xwhite 4 21 22 23 24
- Xwhite 4 25 26 27 28
- Xwhite 4 29 30 31 32
- Xwhite 4 33 34 35 36
- Xwhite 4 37 38 39 40
- Xwhite 4 41 42 43 44
- Xwhite 4 45 46 47 48
- Xwhite 4 49 50 51 52
- Xwhite 4 53 54 55 56
- Xwhite 4 57 58 59 60
- Xwhite 4 61 62 63 64
- Xwhite 4 65 66 67 68
- Xwhite 4 69 70 71 72
- Xwhite 4 73 74 75 76
- Xwhite 4 77 78 79 80
- Xwhite 4 81 82 83 84
- Xwhite 4 85 86 87 88
- Xwhite 4 89 90 91 92
- Xwhite 4 93 94 95 96
- Xwhite 4 97 98 99 100
- Xwhite 4 101 102 103 104
- Xwhite 4 105 106 107 108
- Xwhite 4 109 110 111 112
- Xwhite 4 113 114 115 116
- Xwhite 4 117 118 119 120
- Xwhite 4 121 122 123 124
- Xwhite 4 125 126 127 128
- Xwhite 4 129 130 131 132
- Xwhite 4 133 134 135 136
- Xwhite 4 137 138 139 140
- Xwhite 4 141 142 143 144
- Xwhite 4 145 146 147 148
- Xwhite 4 149 150 151 152
- Xwhite 4 153 154 155 156
- Xwhite 4 157 158 159 160
- Xwhite 4 161 162 163 164
- Xwhite 4 165 166 167 168
- Xwhite 4 169 170 171 172
- Xwhite 4 173 174 175 176
- Xwhite 4 177 178 179 180
- Xwhite 4 181 182 183 184
- Xwhite 4 185 186 187 188
- Xwhite 4 189 190 191 192
- Xwhite 4 193 194 195 196
- Xwhite 4 197 198 199 200
- Xwhite 4 201 202 203 204
- Xwhite 4 205 206 207 208
- Xwhite 4 209 210 211 212
- Xwhite 4 213 214 215 216
- Xwhite 4 217 218 219 220
- Xwhite 4 221 222 223 224
- Xwhite 4 225 226 227 228
- Xwhite 4 229 230 231 232
- Xwhite 4 233 234 235 236
- Xwhite 4 237 238 239 240
- Xwhite 4 241 242 243 244
- Xwhite 4 245 246 247 248
- Xwhite 4 249 250 251 252
- Xwhite 4 253 254 255 256
- Xwhite 4 257 258 259 260
- Xwhite 4 261 262 263 264
- Xwhite 4 265 266 267 268
- Xwhite 4 269 270 271 272
- Xwhite 4 273 274 275 276
- Xwhite 4 277 278 279 280
- *-*-END-of-./V/test/fullrwy-*-*
- echo x - ./V/test/hold
- sed 's/^X//' >./V/test/hold <<'*-*-END-of-./V/test/hold-*-*'
- XF-16-fighter
- X122 11
- X1 -18.165 0 0
- X2 -18.165 -1.191 0
- X3 -15.187 -2.085 0
- X4 -13.698 -2.382 0
- X5 -17.272 -2.382 0
- X6 -17.272 -3.573 0
- X7 -10.923 -3.573 0
- X8 -4.169 -3.573 0
- X9 -4.169 -4.765 0
- X10 5.598 -4.765 0
- X11 18.463 -2.144 0
- X12 18.939 -1.787 0
- X13 22.274 -1.489 0
- X14 24.895 -1.191 0
- X15 27.992 0 0
- X16 -6.551 -3.573 0
- X17 -6.551 -15.485 0
- X18 0.357 -15.485 0
- X19 0.357 -15.187 0
- X20 -2.978 -15.008 0
- X21 5.598 -4.765 0
- X22 -4.169 -4.765 0
- X23 -4.169 -3.573 0
- X24 -17.272 -3.573 0
- X25 -17.272 -8.934 0.893
- X26 -15.187 -8.934 0.893
- X27 -10.923 -3.573 0
- X28 27.992 0 0
- X29 24.895 1.191 0
- X30 22.274 1.489 0
- X31 18.939 1.787 0
- X32 18.463 2.144 0
- X33 5.598 4.765 0
- X34 -4.169 4.765 0
- X35 -4.169 3.573 0
- X36 -10.923 3.573 0
- X37 -17.272 3.573 0
- X38 -17.272 2.382 0
- X39 -13.698 2.382 0
- X40 -15.187 2.085 0
- X41 -18.165 1.191 0
- X42 -18.165 0 0
- X43 5.598 4.765 0
- X44 -2.978 15.008 0
- X45 0.357 15.187 0
- X46 0.357 15.485 0
- X47 -6.551 15.485 0
- X48 -6.551 3.573 0
- X49 -4.169 3.573 0
- X50 -4.169 4.765 0
- X51 -10.923 3.573 0
- X52 -15.187 8.934 0.893
- X53 -17.272 8.934 0.893
- X54 -17.272 3.573 0
- X55 27.992 0 0
- X56 23.525 0 -1.191
- X57 17.272 0 -2.382
- X58 15.783 0 -3.812
- X59 13.996 0 -4.169
- X60 11.316 0 -4.05
- X61 8.338 0 -3.335
- X62 1.787 0 -2.382
- X63 -4.169 0 -2.382
- X64 -13.936 0 -1.906
- X65 -15.128 0 -1.906
- X66 -15.187 0 -1.787
- X67 -18.165 0 -1.191
- X68 -18.165 0 0
- X69 -4.169 0 -2.382
- X70 -10.125 0 -4.05
- X71 -15.783 0 -10.482
- X72 -19.654 0 -10.482
- X73 -19.654 0 -9.529
- X74 -19.654 0 -9.529
- X75 -16.378 0 -3.573
- X76 -16.378 0 -2.144
- X77 -14.889 0 -2.382
- X78 -13.936 0 -2.382
- X79 -13.936 0 -1.906
- X80 -18.165 0 0
- X81 -18.165 0 1.191
- X82 -15.187 0 2.085
- X83 -13.698 0 2.263
- X84 -2.68 0 2.382
- X85 8.04 0 2.382
- X86 12.507 0 2.263
- X87 12.507 0 0.596
- X88 19.952 0 0.596
- X89 23.525 0 0.476
- X90 27.992 0 0
- X91 -3.551 0 -2.382
- X92 -3.551 -3.871 -0.10
- X93 -3.551 -15.485 0
- X94 -3.551 -15.485 0.1065
- X95 -3.551 -3.871 0.142
- X96 -3.551 -2.58 0.2556
- X97 -3.551 -2.387 1.818
- X98 -3.551 -2.102 2.015
- X99 -3.551 -1.03 2.251
- X100 -3.551 0 2.282
- X101 -3.551 1.03 2.251
- X102 -3.551 2.102 2.015
- X103 -3.551 2.387 1.818
- X104 -3.551 2.58 0.2556
- X105 -3.551 3.871 0.142
- X106 -3.551 15.485 0.1065
- X107 -3.551 15.485 0
- X108 -3.551 3.871 -0.10
- X109 13.996 0 -4.169
- X110 13.996 -0.8932 -3.692
- X111 13.996 -1.191 -2.978
- X112 13.996 -1.251 -2.502
- X113 13.996 -1.787 -1.311
- X114 13.996 -3.054 0
- X115 13.996 -1.583 0.3568
- X116 13.996 0 0.596
- X117 13.996 1.583 0.3568
- X118 13.996 3.054 0
- X119 13.996 1.787 -1.311
- X120 13.996 1.251 -2.502
- X121 13.996 1.191 -2.978
- X122 13.996 0.8932 -3.692
- Xgray 14 109 110 111 112 113 114 115 116 117 118 119 120 121 122
- Xgray 18 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
- Xgray 15 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
- Xgray 8 16 17 18 19 20 21 22 23
- Xgray 4 24 25 26 27
- Xgray 15 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
- Xgray 8 43 44 45 46 47 48 49 50
- Xgray 4 51 52 53 54
- Xgray 14 55 56 57 58 59 60 61 62 63 64 65 66 67 68
- Xgray 11 69 70 71 72 73 74 75 76 77 78 79
- Xgray 11 80 81 82 83 84 85 86 87 88 89 90
- *-*-END-of-./V/test/hold-*-*
- echo x - ./fsim
- sed 's/^X//' >./fsim <<'*-*-END-of-./fsim-*-*'
- *-*-END-of-./fsim-*-*
- echo x - ./fsim/pm.c
- sed 's/^X//' >./fsim/pm.c <<'*-*-END-of-./fsim/pm.c-*-*'
- X/*
- X * xflight : an aerial combat simulator for X
- X *
- X * Written by Riley Rainey, riley@mips.com
- X *
- X * Permission to use, copy, modify and distribute (without charge) this
- X * software, documentation, images, etc. is granted, provided that this
- X * comment and the author's name is retained.
- X *
- X */
- X
- X#include <stdio.h>
- X#include <math.h>
- X#include "pm.h"
- X
- Xint debug = 0;
- X
- X/*
- X * A Flight Simulator
- X *
- X * Riley Rainey
- X */
- X
- X/*
- X * We keep a table of atmospheric constants for different altitudes.
- X * These values are important to flight calculations.
- X */
- X
- Xstruct {
- X double alt; /* altitude in feet */
- X double rho; /* rho value (air density) */
- X double speedOfSound; /* speed of sound in feet per second */
- X } *rhop, rhoTable[] = {
- X 0.0, 23.77, 1116.9,
- X 2.0, 22.41, 1109.2,
- X 4.0, 21.11, 1101.4,
- X 6.0, 19.87, 1093.6,
- X 8.0, 18.68, 1085.7,
- X 10.0, 17.55, 1077.8,
- X 15.0, 14.96, 1057.7,
- X 20.0, 12.66, 1037.3,
- X 25.0, 10.65, 1016.4,
- X 30.0, 8.89, 995.1,
- X 35.0, 7.365, 973.3,
- X 40.0, 5.851, 968.5,
- X 50.0, 3.618, 968.5,
- X 60.0, 2.238, 968.5,
- X 80.0, 0.9065, 980.0,
- X 100.0, 0.3371, 1015.0,
- X 120.0, 0.1340, 1053.0,
- X 160.0, 0.02622, 1083.0,
- X 100000.0, 0.02622, 1083.0}; /* a large value for alt at the end */
- X
- Xdouble deltaT; /* Update interval in seconds */
- Xdouble halfDeltaTSquared; /* 0.5 * deltaT * deltaT */
- Xdouble CM, CN;
- X
- X/*
- X * calcRho : Calculate air density by interpolation.
- X */
- X
- Xdouble calcRho (alt)
- Xdouble alt; {
- X
- X double deltaAlt, b;
- X
- X alt = alt / 1000.0;
- X
- X for (rhop=rhoTable; alt>rhop->alt; ++rhop) ;
- X deltaAlt = (rhop+1)->alt - rhop->alt;
- X b = ((rhop+1)->rho - rhop->rho) / deltaAlt;
- X return (rhop->rho + b * (alt - rhop->alt)) / 10000.0;
- X
- X}
- X
- X/*
- X * calcCoefficients : Calculate CLift and friends
- X */
- X
- Xvoid calcCoefficients (c, CLift, CDrag)
- Xcraft *c;
- Xdouble *CLift, *CDrag; {
- X
- X double CDAlpha, CDBeta;
- X
- X/*
- X * We used to interpolate these values, but now use several characteristic
- X * equations to compute these values for a given alpha value. The basic
- X * formulas are:
- X *
- X *
- X * C = C + (alpha * (C + sin(curFlap) * cFlap ))
- X * L LOrigin LSlope
- X *
- X *
- X * C = C + (C * Cos (alpha + C ))
- X * D DOrigin DFactor DPhase
- X *
- X * There are independent equations defining drag resulting from alpha
- X * and beta values. The hypoteneuse of those two values becomes the
- X * resultant CDrag value.
- X */
- X
- X if (c->alpha < c->cinfo->CLNegStall || c->alpha > c->cinfo->CLPosStall) {
- X
- X *CLift = 0.0;
- X CM = c->cinfo->cmFactor * sin (c->alpha);
- X }
- X else {
- X *CLift = c->cinfo->CLOrigin +
- X (c->cinfo->CLSlope + sin (c->curFlap) * c->cinfo->cFlap)
- X * c->alpha;
- X CM = (c->alpha - c->Se * c->cinfo->effElevator) * c->cinfo->cmSlope;
- X }
- X
- X/* CDAlpha = c->cinfo->CDOrigin + c->cinfo->CDFactor *
- X cos (c->alpha + c->cinfo->CDPhase);
- X*/
- X
- X CDAlpha = c->cinfo->CDOrigin +
- X *CLift * *CLift / (pi * c->cinfo->aspectRatio);
- X CDAlpha += sin (c->curSpeedBrake) * c->cinfo->cSpeedBrake;
- X
- X if (fabs(c->beta) > c->cinfo->betaStall)
- X CN = c->cinfo->cnFactor * sin (c->beta);
- X else
- X CN = (c->beta - c->Sr) * c->cinfo->cnSlope;
- X
- X CDBeta = c->cinfo->CDBOrigin + c->cinfo->CDBFactor *
- X cos (c->beta + c->cinfo->CDBPhase);
- X
- X *CDrag = sqrt (CDAlpha * CDAlpha + CDBeta * CDBeta);
- X
- X}
- X
- Xdouble heading (x)
- XVPoint *x; {
- X
- X double m;
- X
- X if (x->x == 0.0 && x->y == 0.0)
- X return 0.0;
- X
- X if ((m = atan2 (x->y, x->x)) < 0.0)
- X return (pi * 2.0 + m);
- X else
- X return m;
- X}
- X
- Xvoid pitchAndRoll (x, y, p, r)
- XVPoint *x;
- XVPoint *y;
- Xdouble *p;
- Xdouble *r; {
- X
- X double h;
- X
- X h = sqrt (x->x * x->x + x->y * x->y);
- X/*
- X * Is all this needed?
- X */
- X if (h == 0.0)
- X if (x->z > 0.0)
- X *p = pi * 0.5;
- X else
- X *p = - pi * 0.5;
- X else
- X *p = atan2 (x->z, h);
- X
- X h = sqrt (y->x * y->x + y->y * y->y);
- X *r = atan2 (y->z, h);
- X}
- X
- Xvoid craftToGround (c, p, g)
- Xcraft *c;
- XVPoint *p;
- XVPoint *g; {
- X
- X VTransform (p, &(c->trihedral), g);
- X
- X}
- X
- Xvoid calcGForces (c, f, w)
- Xcraft *c;
- XVPoint *f;
- Xdouble w; {
- X
- X VPoint t;
- X
- X t = *f;
- X t.z -= w;
- X
- X VTransform (&t, &(c->Itrihedral), &(c->G));
- X c->G.x = - c->G.x / w;
- X c->G.y = - c->G.y / w;
- X c->G.z = - c->G.z / w;
- X}
- X
- Xvoid calcAlphaBeta (c, alpha, beta)
- Xcraft *c;
- Xdouble *alpha, *beta; {
- X
- X VPoint C;
- X double h;
- X
- X if (mag(c->Cg) > 0.0) {
- X VTransform (&(c->Cg), &(c->Itrihedral), &C);
- X *alpha = atan2 (C.z, C.x);
- X h = sqrt (C.z * C.z + C.x * C.x);
- X *beta = atan2 (C.y, h);
- X }
- X else {
- X *alpha = 0.0;
- X *beta = 0.0;
- X }
- X
- X}
- X
- X/*
- X * buildEulerMatrix : Build a transformation matrix based on the supplied
- X * euler angles.
- X */
- X
- Xvoid buildEulerMatrix (roll, pitch, heading, m)
- Xdouble roll, pitch, heading;
- XVMatrix *m; {
- X
- X VIdentMatrix (m);
- X if (roll != 0.0)
- X VRotate (m, XRotation, roll);
- X if (pitch != 0.0)
- X VRotate (m, YRotation, -pitch);
- X if (heading != 0.0)
- X VRotate (m, ZRotation, heading);
- X}
- X
- Xint flightCalculations (c)
- Xcraft *c; {
- X
- X double q, CLift, CDrag;
- X double FLift, FDrag, FWeight;
- X double Vmag, D, angle;
- X double ar, ap, aq, cosR, sinR;
- X double deltaRoll, deltaPitch, deltaYaw;
- X double muStatic, muKinetic;
- X double ke, be;
- X VPoint F, Fg, V, tmpPt, r;
- X VMatrix turn, tmpMatrix, mtx;
- X int positionUpdated = 0;
- X
- X c->prevSg = c->Sg;
- X
- X c->rho = calcRho (-(c->Sg.z));
- X calcAlphaBeta(c, &(c->alpha), &(c->beta));
- X
- X/*
- X * A note about thrust: Normal thrust deminishes in proportion to the decrease in
- X * air density. Afterburners are not affectected in this way. The following formula
- X * approximates this effect.
- X */
- X
- X c->curThrust = calcThrust(c);
- X calcCoefficients (c, &CLift, &CDrag);
- X
- X if (debug)
- X printf ("alpha = %g, beta = %g\nCL = %g, CD = %g\n", RADtoDEG(c->alpha),
- X RADtoDEG(c->beta), CLift, CDrag);
- X
- X
- X/*
- X * Compute the resultant force vector on the aircraft.
- X */
- X
- X Vmag = mag(c->Cg);
- X q = c->rho * c->cinfo->wingS * Vmag * Vmag * 0.5;
- X FLift = CLift * q;
- X FDrag = CDrag * q;
- X
- X if (debug) {
- X printf ("rho = %g, FLift = %g, FDrag = %g\n", c->rho, FLift, FDrag);
- X printf ("FThrust = %g\n", c->curThrust);
- X }
- X
- X F.x = c->curThrust - sin(c->alpha) * cos(c->beta) * FLift -
- X cos(c->alpha) * cos(c->beta) * FDrag;
- X F.y = sin(c->alpha) * sin(c->beta) * FLift - sin(c->alpha) * sin(c->beta) *
- X FDrag;
- X F.z = -cos(c->alpha) * cos(c->beta) * FLift - sin(c->alpha) * cos(c->beta) *
- X FDrag;
- X
- X/*
- X * Get ground friction coefficients
- X */
- X
- X if (c->groundContact)
- X if (c->flags & FL_BRAKES) {
- X muStatic = c->cinfo->muBStatic;
- X muKinetic = c->cinfo->muBKinetic;
- X }
- X else {
- X muStatic = c->cinfo->muStatic;
- X muKinetic = c->cinfo->muKinetic;
- X }
- X
- X/*
- X * Now calculate changes in position (Sg) and velocity (Cg).
- X */
- X
- X if (Vmag > c->cinfo->maxNWS || c->groundContact == 0)
- X c->flags &= ~FL_NWS;
- X else
- X c->flags |= FL_NWS;
- X
- X if (c->flags & FL_NWS) {
- X
- X c->curNWDef = c->Sa * c->cinfo->maxNWDef;
- X
- X if (c->curNWDef != 0.0) {
- X
- X r.x = c->cinfo->gearD2;
- X r.y = c->cinfo->gearD1 / tan(c->curNWDef);
- X r.z = 0.0;
- X angle = Vmag / r.y * deltaT;
- X
- X/*
- X * Nose wheel steering mode.
- X * Relocate the aircraft and its trihedral (this code assumes that the
- X * plane is rolling on a flat surface (i.e. z is constant).
- X */
- X
- X tmpPt = r;
- X VTransform(&tmpPt, &(c->trihedral), &r);
- X
- X VIdentMatrix (&turn);
- X turn.m[0][3] = - c->Sg.x - r.x;
- X turn.m[1][3] = - c->Sg.y - r.y;
- X turn.m[2][3] = - c->Sg.z;
- X VRotate (&turn, ZRotation, angle);
- X turn.m[0][3] = turn.m[0][3] + c->Sg.x + r.x;
- X turn.m[1][3] = turn.m[1][3] + c->Sg.y + r.y;
- X turn.m[2][3] = turn.m[2][3] + c->Sg.z;
- X VTransform (&(c->Sg), &turn, &tmpPt);
- X c->Sg = tmpPt;
- X
- X VIdentMatrix (&turn);
- X VRotate (&turn, ZRotation, angle);
- X tmpMatrix = c->trihedral;
- X VMatrixMult (&tmpMatrix, &turn, &(c->trihedral));
- X VTransform (&(c->Cg), &turn, &tmpPt);
- X c->Cg = tmpPt;
- X
- X transpose (&c->trihedral, &c->Itrihedral);
- X
- X addHeading (c, angle);
- X positionUpdated = 1;
- X }
- X
- X craftToGround (c, &F, &Fg);
- X FWeight = c->cinfo->emptyWeight + c->fuel;
- X
- X if ((c->fuel -= fuelUsed(c)) <= 0.0) {
- X c->fuel = 0.0;
- X c->curThrust = 0.0;
- X c->throttle = 0;
- X }
- X
- X Fg.z += FWeight;
- X
- X/*
- X * Factor in ground friction for both static and moving planes.
- X */
- X
- X if (c->Cg.x + c->Cg.y == 0.0 && sqrt (Fg.x*Fg.x + Fg.y*Fg.y) <=
- X muStatic * Fg.z) {
- X Fg.x = 0.0;
- X Fg.y = 0.0;
- X }
- X else {
- X
- X/*
- X * Okay, the plane is moving. Quantify the current kinetic energy of the
- X * moving craft and add the energy added this period by all forces EXCEPT
- X * ground friction (we'll name this "ke"). If the energy removed by the friction
- X * force is greater than ke, then the craft will stop sometime during this
- X * period -- we won't bother to calculate exactly where we stop; just zero out
- X * the x and y force and velocity components.
- X */
- X
- X ke = 0.5 * FWeight / a * sqrt (c->Cg.x * c->Cg.x +
- X c->Cg.y * c->Cg.y);
- X ke += pow(sqrt(Fg.x * Fg.x + Fg.y * Fg.y), 2.0) *
- X halfDeltaTSquared * a / FWeight;
- X be = pow(Fg.z * muKinetic, 2.0) * halfDeltaTSquared * a / FWeight;
- X if (be >= ke) {
- X Fg.x = 0.0;
- X Fg.y = 0.0;
- X c->Cg.x = 0.0;
- X c->Cg.y = 0.0;
- X }
- X else {
- X
- X/*
- X * Getting to this point means that we're rolling along the ground (and not stopping)
- X * -- make sure our roll is zeroed, then cancel the local Y-component of our
- X * velocity vector (tires don't roll sideways) and then calculate the drag
- X * contributed by the rolling wheels.
- X */
- X
- X c->curRoll = 0.0;
- X VTransform (&(c->Cg), &(c->Itrihedral), &V);
- X V.y = 0.0;
- X VTransform (&V, &(c->trihedral), &(c->Cg));
- X D = Fg.z * muKinetic;
- X Vmag = mag (c->Cg);
- X if (Vmag > 0.0) {
- X Fg.x -= D * c->Cg.x / Vmag;
- X Fg.y -= D * c->Cg.y / Vmag;
- X Fg.z -= D * c->Cg.z / Vmag;
- X }
- X }
- X }
- X
- X
- X/* Nose wheel steering is only active when we cannot lift off -- cancel z */
- X
- X Fg.z = 0.0;
- X calcGForces (c, &Fg, FWeight);
- X
- X }
- X else {
- X
- X/*
- X * Resolve moments
- X */
- X
- X ap = fsign (c->p);
- X aq = fsign (c->q);
- X ar = fsign (c->r);
- X if (c->groundContact == 0) {
- X ap = (c->Sa * c->cinfo->effAileron * q - c->cinfo->LDamp *
- X ap * c->p * c->p * 0.5) / c->cinfo->I.m[0][0];
- X ap += c->beta * c->cinfo->CLbeta * q / c->cinfo->I.m[0][0];
- X }
- X else
- X ap = 0.0;
- X
- X aq = (CM * q - c->cinfo->MDamp * aq * c->q * c->q * 0.5) /
- X c->cinfo->I.m[1][1];
- X ar = (CN * q - c->cinfo->NDamp * ar * c->r * c->r * 0.5) /
- X c->cinfo->I.m[2][2];
- X
- X if (debug)
- X printf ("ap = %g, aq = %g, ar = %g\n", ap, aq, ar);
- X
- X deltaRoll = c->p * deltaT + ap * halfDeltaTSquared;
- X deltaPitch = c->q * deltaT + aq * halfDeltaTSquared;
- X deltaYaw = c->r * deltaT + ar * halfDeltaTSquared;
- X c->p = c->p + ap * deltaT;
- X c->q = c->q + aq * deltaT;
- X c->r = c->r + ar * deltaT;
- X
- X cosR = cos (c->curRoll);
- X sinR = sin (c->curRoll);
- X
- X
- X c->curRoll += deltaRoll;
- X c->curHeading += sinR * deltaPitch + cosR * deltaYaw;
- X c->curPitch += cosR * deltaPitch - sinR * deltaYaw;
- X
- X/*
- X * Normalize picth and heading Euler angles
- X */
- X
- X if (c->curPitch > pi / 2.0) {
- X c->curPitch = pi - c->curPitch;
- X c->curHeading = (c->curHeading > pi) ?
- X c->curHeading - pi : c->curHeading + pi;
- X c->curRoll = pi - c->curRoll;
- X }
- X else if (c->curPitch < -pi/2.0) {
- X c->curPitch = -pi - c->curPitch;
- X c->curHeading = (c->curHeading > pi) ?
- X c->curHeading - pi : c->curHeading + pi;
- X c->curRoll = pi - c->curRoll;
- X }
- X
- X if (c->curHeading < 0.0) {
- X c->curHeading += 2.0 * pi;
- X }
- X else if (c->curHeading > 2.0 * pi) {
- X c->curHeading -= 2.0 * pi;
- X }
- X
- X/*
- X * Compute transformation matrices
- X */
- X
- X buildEulerMatrix (c->curRoll, c->curPitch, c->curHeading, &(c->trihedral));
- X transpose (&c->trihedral, &c->Itrihedral);
- X
- X craftToGround (c, &F, &Fg);
- X FWeight = c->cinfo->emptyWeight + c->fuel;
- X
- X if ((c->fuel -= fuelUsed(c)) <= 0.0) {
- X c->fuel = 0.0;
- X c->curThrust = 0.0;
- X }
- X
- X Fg.z += FWeight;
- X
- X/*
- X * If we are on the ground, level the wings and compute wheel drag forces. Wheel
- X * drag always acts in the opposite direction of the velocity vector.
- X */
- X
- X if (c->groundContact) {
- X c->curRoll = 0.0;
- X VTransform (&(c->Cg), &(c->Itrihedral), &V);
- X V.y = 0.0;
- X VTransform (&V, &(c->trihedral), &(c->Cg));
- X D = Fg.z * muKinetic;
- X Vmag = mag (c->Cg);
- X Fg.x -= D * c->Cg.x / Vmag;
- X Fg.y -= D * c->Cg.y / Vmag;
- X Fg.z -= D * c->Cg.z / Vmag;
- X }
- X
- X if (debug) {
- X printf ("v = %g, Fg = { %g, %g, %g }\n", FPStoKTS(Vmag),
- X Fg.x, Fg.y, Fg.z);
- X printf ("F = { %g, %g, %g }\n",
- X F.x, F.y, F.z);
- X }
- X
- X
- X/*
- X * Are we on the ground without the prospect of gaining altitude?
- X * If so, cancel the vertical force component.
- X */
- X
- X if (c->groundContact && Fg.z > 0.0)
- X Fg.z = 0.0;
- X
- X calcGForces (c, &Fg, FWeight);
- X
- X
- X }
- X
- X/*
- X * Update our position (in flight mode).
- X */
- X
- X if (positionUpdated == 0) {
- X
- X c->Sg.x += c->Cg.x * deltaT + Fg.x / FWeight
- X * a * halfDeltaTSquared;
- X c->Sg.y += c->Cg.y * deltaT + Fg.y / FWeight
- X * a * halfDeltaTSquared;
- X c->Sg.z += c->Cg.z * deltaT + Fg.z / FWeight
- X * a * halfDeltaTSquared;
- X
- X }
- X
- X c->Cg.x += Fg.x / FWeight * a * deltaT;
- X c->Cg.y += Fg.y / FWeight * a * deltaT;
- X c->Cg.z += Fg.z / FWeight * a * deltaT;
- X
- X if (debug) {
- X printf ("Altitude = %g\n", -c->Sg.z);
- X printf ("Euler angles { %g, %g, %g }\n", RADtoDEG(c->curRoll),
- X RADtoDEG(c->curPitch), RADtoDEG(c->curHeading));
- X printf ("Cg = { %g, %g, %g }\n", c->Cg.x, c->Cg.y, c->Cg.z);
- X printf ("Sg = { %g, %g, %g }\n", c->Sg.x, c->Sg.y, c->Sg.z);
- X
- X printf ("X = { %g, %g, %g }\n", c->trihedral.m[0][0],
- X c->trihedral.m[1][0], c->trihedral.m[2][0]);
- X printf ("Z = { %g, %g, %g }\n\n", c->trihedral.m[0][2],
- X c->trihedral.m[1][2], c->trihedral.m[2][2]);
- X }
- X
- X
- X/*
- X * Normalize the vertical position. If our altitude is now below our
- X * contact threshold, mark us as having "groundContact" and adjust the
- X * altitude.
- X */
- X
- X if (c->Sg.z >= - c->cinfo->groundingPoint.z) {
- X c->groundContact = 1;
- X c->Sg.z = - c->cinfo->groundingPoint.z;
- X
- X/*
- X * If the vertical velocity component is too great, the plane has crashed ...
- X */
- X
- X if (c->Cg.z > c->cinfo->crashC)
- X return 1;
- X else
- X c->Cg.z = 0.0;
- X
- X }
- X else {
- X c->groundContact = 0;
- X c->flags &= ~FL_NWS;
- X }
- X
- X
- X return 0;
- X}
- *-*-END-of-./fsim/pm.c-*-*
- echo x - ./fsim/pm.h
- sed 's/^X//' >./fsim/pm.h <<'*-*-END-of-./fsim/pm.h-*-*'
- X#include "manifest.h"
- X#include "eng.xbm"
- X#include "flaps0.xbm"
- X#include "flaps1.xbm"
- X#include "flaps2.xbm"
- X#include "flaps3.xbm"
- X#include "scale.h"
- X#include <Vlib.h>
- X
- X#define MAXSURFACE 8
- X#define MAXPLAYERS 16
- X#define MAXPROJECTILES MAXPLAYERS*8
- X#define MAXCRAFTTYPES 16
- X#define STATIONS 9
- X#define WEAPONTYPES 4
- X
- Xtypedef struct _viewer {
- X struct _viewer *next;
- X Display *dpy; /* display for this user */
- X Window win; /* window for this user */
- X Window twin, rwin; /* threat window and radar window */
- X GC gc; /* GC for drawing */
- X XFontStruct *font; /* HUD font */
- X XFontStruct *rfont; /* radar font */
- X Viewport *v; /* Viewport for out-of-cockpit views */
- X Pixmap eng; /* Engine "RPM" gauge */
- X Pixmap flap[5]; /* flap setting indicators */
- X int cn; /* X connection fd */
- X int width, height; /* width & height of viewing window */
- X int xCenter, yCenter; /* center of viewing window */
- X int ftw, fth; /* HUD font width & height */
- X int rftw, rfth;
- X int radarWidth;
- X int radarHeight;
- X scaleControl altScale; /* altitude scale control */
- X scaleControl velScale; /* airspeed scale control */
- X scaleControl hdgScale; /* heading scale control */
- X int TEWSx, TEWSy; /* location of center of TEWS display */
- X int TEWSSize; /* size of TEWS display, in pixels */
- X } viewer;
- X
- X/*
- X * This structure describes a class of aircraft.
- X */
- X
- Xtypedef struct {
- X char *name; /* name of aircraft class */
- X
- X double aspectRatio; /* wing aspect ratio */
- X
- X double CLOrigin, CLSlope; /* Defines the CL characteristic eqn */
- X double CLNegStall, CLPosStall;
- X double betaStall; /* Stall angle for rudder */
- X double CDOrigin, CDFactor; /* Defines the CD Characteristic eqn */
- X double CDPhase;
- X double CDBOrigin, CDBFactor; /* Defines the CD Characteristic eqn */
- X double CDBPhase;
- X double CLbeta; /* coefficient rolling moment due to sideslip */
- X double CMOrigin, CMFactor; /* Defines the CM Characteristic eqn */
- X double CNOrigin, CNFactor; /* Defines the CM Characteristic eqn */
- X
- X double effAileron; /* Aileron effectiveness */
- X double effElevator; /* Elevator effectiveness */
- X double effRudder; /* Rudder effectiveness */
- X
- X VMatrix I; /* Moments of Intertia about CG in [xyz] */
- X double LDamp; /* roll damping factor */
- X double MDamp; /* pitch damping factor */
- X double NDamp; /* yaw damping factor */
- X double cmSlope;
- X double cmFactor;
- X double cnSlope;
- X double cnFactor;
- X
- X double maxFlap; /* maximum flap setting (radians) */
- X double cFlap; /* lift coefficient of flaps */
- X double flapRate; /* flap movement rate (radians/sec) */
- X
- X double maxSpeedBrake; /* maximum speed brake setting (radians) */
- X double cSpeedBrake; /* drag coefficient of 90 degree speed brake */
- X double speedBrakeRate; /* rate of speed brake movement (radians/sec) */
- X double speedBrakeIncr; /* number of radians than one keystroke moves brake */
- X
- X double wingS; /* wing area (ft^2) */
- X double emptyWeight; /* empty weight (lbs.) */
- X double maxFuel; /* maximum internal fuel (lbs.) */
- X
- X double maxThrust; /* maximum thrust, military power (lb) */
- X double maxABThrust; /* maximum thrust, afterburner on (lb) */
- X double spFuelConsump; /* specific fuel consump(lb fuel/lb T x hr)*/
- X double spABFuelConsump;
- X VPoint groundingPoint; /* hypothetical single pt of contact w/ground */
- X VPoint viewPoint; /* pilot's viewing location wrt CG */
- X double crashC; /* maximum tolerable touchdown z component */
- X
- X double muStatic; /* static coefficient of friction no-brakes */
- X double muKinetic; /* moving coefficient of friction no-brakes */
- X double muBStatic; /* static brakes-on */
- X double muBKinetic; /* kinetic brakes-on */
- X
- X double maxNWDef; /* maximum nosewheel deflection (radians) */
- X double NWIncr; /* deflection for each unit */
- X double maxNWS; /* maximum NWS velocity */
- X double gearD1; /* x station wrt nose gear of main gear */
- X double gearD2; /* x station wrt CG of main gear */
- X double armDelay; /* arming delay for missiles */
- X double radarOutput; /* radar output (watts) */
- X double radarTRange; /* tracking radar range */
- X double radarDRange; /* detection radar range */
- X double TEWSThreshold;
- X
- X int sCount; /* number of weapon stations */
- X VPoint wStation[STATIONS]; /* weapon's stations (launch points) */
- X
- X int (*placeProc)(); /* object placement procedure (for special craft) */
- X VObject *object; /* what it looks like */
- X } craftType;
- X
- Xtypedef struct _wdsc {
- X int mask; /* key mask */
- X int (*select)(); /* weapon select procedure */
- X int (*update)(); /* per tick update procedure */
- X int (*display)(); /* display update procedure */
- X int (*firePress)(); /* fire button pressed procedure */
- X int (*fireRelease)(); /* fire button released */
- X craftType *w; /* description of this weapon */
- X } weaponDesc;
- X
- Xtypedef struct _wctl {
- X int type; /* type of weapon at this station */
- X int info; /* extra info (weapon specific) */
- X int info2; /* " " */
- X int info3; /* " " */
- X } weaponStation;
- X
- X#define WK_M61A1 0x01 /* M-61A1 Vulcan 20mm cannon */
- X#define WK_AIM9M 0x02 /* Sidewinder missile */
- X
- X/*
- X * This structure describes a particular instance of aircraft.
- X */
- X
- Xtypedef struct _craft {
- X int index; /* index number of this element in the vector */
- X int type; /* craft type */
- X int team; /* team number */
- X double createTime; /* creation time of this craft */
- X viewer *vl; /* list of viewers */
- X VMatrix trihedral; /* transforms [x, y, z] to Geoparallel */
- X /* x = forward, y=right wing, z=down */
- X /* does not include origin translation */
- X VMatrix Itrihedral; /* transforms geoparallel to [x, y, z] */
- X VPoint C; /* Velocity vector in [x, y, z] */
- X VPoint Cg; /* Velocity vector in Geoparallel system */
- X VPoint Sg; /* Position in Geoparallel system */
- X double rho; /* current rho value */
- X VPoint G; /* g-force vector in acft system */
- X VPoint prevSg; /* last interval's Sg value */
- X double p, q, r; /* roll, pitch, and yaw rates */
- X double Se, Sa, Sr; /* control settings */
- X double curHeading, curPitch, curRoll; /* Euler angles for acft */
- X double curThrust; /* Current thrust value */
- X double curFlap; /* current flap setting (radians) */
- X double flapSetting; /* current target flap setting (radians) */
- X double curSpeedBrake; /* current speed brake position (radians) */
- X double speedBrakeSetting; /* current target speed brake setting (radians) */
- X int throttle; /* thrust setting 0 - 32768 */
- X double alpha, beta; /* angles of attack and sideslip */
- X double fuel; /* current fuel on board */
- X int groundContact; /* 1, when on ground */
- X int flags; /* flag word */
- X int radarMode; /* radar mode */
- X double curNWDef; /* Current nosewheel deflection (radians) */
- X int armFuse; /* missile arming countdown */
- X craftType *cinfo; /* General craft information */
- X double order; /* temporary value used to sort craft */
- X struct _craft *next; /* next craft in sorted list */
- X VPoint viewDirection; /* where the pilot is currently looking */
- X VPoint viewUp; /* the "up" direction of the pilot's view */
- X
- X char name[32]; /* logname of player */
- X char display[32]; /* display name of player */
- X
- X short curRadarTarget; /* our primary "threat" */
- X double targetDistance; /* distance to primary target */
- X double targetClosure; /* closure rate on primary target */
- X short relValid[MAXPLAYERS];
- X VPoint relPos[MAXPLAYERS];
- X double rval[MAXPLAYERS];/* radar strength seen by us from other craft */
- X /* relative positions of possible targets */
- X char *leftHUD[3]; /* strings in lower left corner of HUD */
- X /* (reserved for weapons' status */
- X char *rightHUD[3]; /* strings in lower right corner of HUD */
- X /* (reserved for future use) */
- X int curWeapon; /* index of currently selected weapon */
- X weaponStation station[STATIONS]; /* what's at each weapon station */
- X } craft;
- X
- X/*
- X * We'll use some defines to reduce the storage required for the craft
- X * (unions would be cleaner, perhaps).
- X */
- X
- X#define rounds curRadarTarget
- X#define tracerMod groundContact
- X#define tracerVal radarMode
- X
- X/*
- X * Craft type definitions
- X */
- X
- X#define CT_FREE 0 /* an unused craft entry */
- X#define CT_PLANE 1 /* a player */
- X#define CT_MISSILE 2 /* an air to air missile */
- X#define CT_CANNON 3 /* a stream of cannon fire */
- X#define CT_SURFACE 4 /* surface object (e.g. a runway) */
- X#define CT_OBSERVER 5 /* a non-player "watcher" */
- X#define CT_DRONE 6 /* a target drone */
- X
- X#define FL_RECORD 0x01 /* activate recording function */
- X#define FL_AFTERBURNER 0x02 /* afterburner state */
- X#define FL_BRAKES 0x04 /* wheel brake state */
- X#define FL_NWS 0x08 /* nose-wheel steering mode */
- X#define FL_HAS_GYRO 0x10 /* missile is gyroscope equiped */
- X
- X#define RM_OFF 0 /* radar is off */
- X#define RM_STANDBY 1 /* standby */
- X#define RM_GUN_DIRECTOR 2 /* gun director mode */
- X#define RM_HUD 3 /* 20 degree scan */
- X#define RM_NORMAL 4 /* 65 degree scan */
- X
- Xint recordCount; /* number of players recording info */
- Xdouble curTime; /* current time */
- X
- Xcraft stbl[MAXSURFACE]; /* table of surface objects */
- Xcraft ptbl[MAXPLAYERS]; /* table of player aircraft */
- Xcraft mtbl[MAXPROJECTILES]; /* table of missiles and cannon streams */
- XweaponDesc wtbl[WEAPONTYPES]; /* descriptions of different weapons */
- X
- Xdouble deltaT; /* Update interval in seconds */
- Xdouble halfDeltaTSquared; /* 0.5 * deltaT * deltaT */
- Xint HUDPixel; /* index of HUD color in viewport(s) */
- XVColor *HUDColor;
- Xint whitePixel; /* index of white in viewport(s) */
- XVColor *whiteColor; /* white in viewport(s) */
- Xint blackPixel; /* index of black in viewport(s) */
- XVColor *blackColor; /* black in viewport(s) */
- XVColor *groundColor; /* ground color in viewport(s) */
- X
- X#define a 32.15 /* acceleration due to gravity (fps^2) */
- X#define pi 3.1415927
- X#define mag(v) (sqrt (v.x * v.x + v.y * v.y + v.z * v.z))
- X#define calcAplha(p) (atan2 (p.C.z, p.C.x))
- X#define calcBeta(p) (atan2 (p.C.y, sqrt (pow (mag(p.C), 2.0) \
- X + p.C.y * p.C.y)))
- X#define unitVector(v) {double m; m = mag(v); \
- X v.x /= m; v.y /= m; v.z /= m; }
- X
- X#define addHeading(c, dh) {c->curHeading = c->curHeading + dh; \
- X if (c->curHeading > pi * 2.0 || c->curHeading <= 0.0) \
- X c->curHeading = (c->curHeading <= 0.0) ? c->curHeading + \
- X 2.0 * pi : c->curHeading - 2.0 * pi; }
- X
- X#define NM 6076.115
- X#define FPStoMPH(v) (v / 5280.0 * 3600.0)
- X#define FPStoKTS(v) (v / 6076.115 * 3600.0)
- X#define RADtoDEG(a) (a * 180.0 / pi)
- X#define DEGtoRAD(a) (a * pi / 180.0)
- X#define fsign(d) (d < 0 ? -1.0 : 1.0)
- X#define calcThrust(c) ((((c->flags & FL_AFTERBURNER) ? \
- X c->cinfo->maxABThrust : c->cinfo->maxThrust) - \
- X c->cinfo->maxThrust * (1.0 - (c->rho / 0.002377))) * \
- X (double) c->throttle / 32768.0)
- X#define fuelUsed(c) (((c->flags & FL_AFTERBURNER) ? \
- X c->cinfo->spABFuelConsump : c->cinfo->spFuelConsump) * c->curThrust * \
- X deltaT / 3600.0)
- X
- X#define VIEW_WINDOW_HEIGHT 500
- X#define VIEW_WINDOW_WIDTH 1200
- X#define RADAR_WINDOW_WIDTH 200
- X#define RADAR_WINDOW_HEIGHT 200
- X#define RADAR_X (1200/2-200/2)
- X#define RADAR_Y (500)
- X#define TEWS_X (1200/2-200/2-100)
- X#define TEWS_Y (VIEW_WINDOW_HEIGHT+60)
- X#define TEWS_SIZE 81
- X#define FS_WINDOW_WIDTH (VIEW_WINDOW_WIDTH)
- X#define FS_WINDOW_HEIGHT (VIEW_WINDOW_HEIGHT+RADAR_WINDOW_HEIGHT)
- X#define FLAP_X (1200/2-200/2-95)
- X#define FLAP_Y (FS_WINDOW_HEIGHT-53)
- X#define DESIGNATOR_SIZE 40
- X
- X/*
- X * Location of the center of the engine RPM gauge.
- X */
- X
- X#define ENG_X (FS_WINDOW_WIDTH-400)
- X#define ENG_Y (VIEW_WINDOW_HEIGHT+60)
- X
- X#define ALT_ORG_X 760
- X#define ALT_ORG_Y 360
- X#define ALT_LENGTH 199
- X#define ALT_ORIENT orientRight
- X#define ALT_SCALE (1700.0 / (double) ALT_LENGTH)
- X#define ALT_INDEX_SIZE 30
- X#define ALT_MIN_INTERVAL 100
- X#define ALT_MIN_SIZE 8
- X#define ALT_MAJ_INTERVAL 500
- X#define ALT_MAJ_SIZE 15
- X#define ALT_DIVISOR 1000.0
- X#define ALT_FORMAT "%4.3g"
- X
- X#define VEL_ORG_X 440
- X#define VEL_ORG_Y 360
- X#define VEL_LENGTH ALT_LENGTH
- X#define VEL_ORIENT 0
- X#define VEL_SCALE (170.0 / (double) VEL_LENGTH)
- X#define VEL_INDEX_SIZE 30
- X#define VEL_MIN_INTERVAL 10
- X#define VEL_MIN_SIZE 8
- X#define VEL_MAJ_INTERVAL 50
- X#define VEL_MAJ_SIZE 15
- X#define VEL_DIVISOR 10.0
- X#define VEL_FORMAT "%3.3g"
- X
- X#define HDG_ORG_X (VIEW_WINDOW_WIDTH / 2 - (6*30+1) / 2)
- X#define HDG_ORG_Y 400
- X#define HDG_LENGTH (6*30+1)
- X#define HDG_ORIENT 0
- X#define HDG_SCALE (3000.0 / (double) VEL_LENGTH)
- X#define HDG_INDEX_SIZE 10
- X#define HDG_MIN_INTERVAL 500
- X#define HDG_MIN_SIZE 5
- X#define HDG_MAJ_INTERVAL 1000
- X#define HDG_MAJ_SIZE 10
- X#define HDG_DIVISOR 1000.0
- X#define HDG_FORMAT "%2.2g"
- *-*-END-of-./fsim/pm.h-*-*
- echo x - ./fsim/doViews.c
- sed 's/^X//' >./fsim/doViews.c <<'*-*-END-of-./fsim/doViews.c-*-*'
- X/*
- X * xflight : an aerial combat simulator for X
- X *
- X * Written by Riley Rainey, riley@mips.com
- X *
- X * Permission to use, copy, modify and distribute (without charge) this
- X * software, documentation, images, etc. is granted, provided that this
- X * comment and the author's name is retained.
- X *
- X */
- X
- X#include "pm.h"
- X#include <math.h>
- X
- X#define lim ((double) -1052500.0)
- X
- Xstatic VPoint horiz[4] = {{-lim, -lim, (double) 0.0},
- X {-lim, lim, (double) 0.0},
- X { lim, lim, (double) 0.0},
- X { lim, -lim, (double) 0.0}};
- X
- X#define MAXPOLYGONS 8192
- X
- Xstatic VPolygon *poly[MAXPOLYGONS];
- X
- Xstatic craft *sortList;
- X
- Xvoid insertCraft();
- X
- Xvoid doViews() {
- X
- X int polyCount;
- X register unsigned long curPixel;
- X register craft *c, *p;
- X register int i, j, k;
- X register viewer *q;
- X VPoint vp, fwd, up;
- X VPoint horiz[4];
- X int mono;
- X
- X/*
- X * Build a vector of polygons for all objects in the scene.
- X *
- X * This vector should be ordered from "most distant" to "closest" so that
- X * the final display will end up correct. Rather than generalizing this
- X * to death, we'll use a few heuristics to get very close to what we need:
- X *
- X * (0) Build a single polygon to represent the ground.
- X * (1) Objects on the surface (stbl) are collected first.
- X * (2) Planes and projectiles (ptbl and mtbl) are first sorted in descending
- X * order by their distance from the observer and then polygons are
- X * collected.
- X */
- X
- X
- X for ((i=0, c=ptbl); i<MAXPLAYERS; (++i, ++c)) {
- X
- X if (c->type == CT_DRONE)
- X doDroneRadar (c);
- X
- X if (c->type != CT_PLANE)
- X continue;
- X
- X/*
- X * Set up the eyespace transformation for this viewpoint
- X */
- X
- X VTransform (&c->cinfo->viewPoint, &(c->trihedral), &vp);
- X vp.x += c->Sg.x;
- X vp.y += c->Sg.y;
- X vp.z += c->Sg.z;
- X
- X VTransform (&c->viewDirection, &(c->trihedral), &fwd);
- X fwd.x += vp.x;
- X fwd.y += vp.y;
- X fwd.z += vp.z;
- X
- X VTransform (&c->viewUp, &(c->trihedral), &up);
- X up.x += vp.x;
- X up.y += vp.y;
- X up.z += vp.z;
- X
- X VGetEyeSpace (c->vl->v, vp, fwd, up);
- X
- X polyCount = 0;
- X sortList = (craft *) NULL;
- X
- X horiz[0].x = c->Sg.x - lim;
- X horiz[0].y = c->Sg.y - lim;
- X horiz[0].z = 0.0;
- X horiz[1].x = c->Sg.x - lim;
- X horiz[1].y = c->Sg.y + lim;
- X horiz[1].z = 0.0;
- X horiz[2].x = c->Sg.x + lim;
- X horiz[2].y = c->Sg.y + lim;
- X horiz[2].z = 0.0;
- X horiz[3].x = c->Sg.x + lim;
- X horiz[3].y = c->Sg.y - lim;
- X horiz[3].z = 0.0;
- X
- X poly[0] = VCreatePolygon (4, &horiz[0], groundColor);
- X polyCount = 1;
- X
- X for ((j=0, p=stbl); j<MAXSURFACE; (++j, ++p)) {
- X if (p->type != CT_FREE)
- X/* placeCraft (p, poly, &polyCount); */
- X insertCraft (c, p);
- X }
- X
- X for ((j=0, p=ptbl); j<MAXPLAYERS; (++j, ++p)) {
- X if (p->type != CT_FREE && p != c) {
- X insertCraft (c, p);
- X }
- X }
- X
- X for ((j=0, p=mtbl); j<MAXPROJECTILES; (++j, ++p)) {
- X if (p->type != CT_FREE)
- X insertCraft (c, p);
- X }
- X
- X for (p=sortList; p != (craft *) NULL; p=(craft *)p->next)
- X placeCraft (p, poly, &polyCount);
- X
- X/*
- X * Clip all polygons
- X */
- X
- X for (j=0; j<polyCount; ++j) {
- X VTransformPolygon (poly[j], &(c->vl->v->eyeSpace));
- X poly[j] = VClipPolygon(poly[j], c->vl->v->clipPoly);
- X }
- X
- X/*
- X * Display this image for each viewer associated with this craft
- X */
- X
- X for (q=c->vl; q != NULL; q = q->next) {
- X
- X mono = q->v->flags & VPMono;
- X curPixel = -1;
- X for (j=0; j<polyCount; ++j) {
- X if (poly[j]) {
- X if (curPixel != (k=q->v->pixel[poly[j]->color->index])) {
- X XSetForeground (q->dpy, q->gc, k);
- X curPixel = k;
- X }
- X VFillPolygon (q->v, q->win, q->gc, poly[j]);
- X }
- X
- X }
- X
- X/* Draw Head-Up Display and instrument panel */
- X
- X doHUD(c, q);
- X doRadar (c, q);
- X doTEWS (c, q); /* doRadar must be called first */
- X doRPM(c, q);
- X
- X/* Expose the completed drawing */
- X
- X VExposeBuffer (q->v, q->gc);
- X
- X/*
- X * Erase the un-displayed planes.
- X */
- X
- X if (mono == 0) {
- X curPixel = *(q->v->pixel);
- X XSetForeground (q->dpy, q->gc, curPixel);
- X XFillRectangle (q->dpy, q->win, q->gc, 0, 0, q->width, q->height);
- X }
- X
- X }
- X
- X/*
- X * Release polygons
- X */
- X
- X for (j=0; j<polyCount; ++j)
- X if (poly[j])
- X VDestroyPolygon (poly[j]);
- X
- X }
- X}
- X
- X/*
- X * insertCraft : Insert a craft into sortList in descending order.
- X */
- X
- Xvoid insertCraft (c, p)
- Xcraft *c, *p; {
- X
- X double dist, offset;
- X VPoint ds;
- X craft *q, *prev;
- X
- X/*
- X * Here's a kludge for you: to avoid polygon clipping, I'm going to
- X * cheat and hack a way to get ground objects to display properly.
- X * if the Z coordinate of an object is zero (i.e. on ground objects),
- X * I'll add a huge offset to their distance values to force them to be
- X * plotted first -- and in roughly their correct drawing order.
- X *
- X */
- X
- X offset = (p->Sg.z == 0.0) ? 1000.0 * NM : 0.0;
- X
- X ds.x = p->Sg.x - c->Sg.x;
- X ds.y = p->Sg.y - c->Sg.y;
- X ds.z = p->Sg.z - c->Sg.z;
- X p->order = dist = mag (ds) + offset;
- X
- X if (sortList != (craft *) NULL) {
- X for ((q=sortList, prev=(craft *) NULL); q != (craft *) NULL;) {
- X if (q->order < dist) {
- X p->next = (struct _craft *) q;
- X if (prev == (craft *) NULL)
- X sortList = p;
- X else
- X prev->next = (struct _craft *) p;
- X break;
- X }
- X prev = q;
- X q = (craft *) q->next;
- X }
- X if (q == (craft *) NULL) {
- X prev->next = (struct _craft *) p;
- X p->next = (struct _craft *) NULL;
- X }
- X }
- X else {
- X sortList = p;
- X p->next = (struct _craft *) NULL;
- X }
- X}
- X
- Xint doHUD (c, u)
- Xcraft *c;
- Xviewer *u; {
- X
- X char buffer[80];
- X int i, x, x1, y;
- X
- X if (c->viewDirection.x < 0.90)
- X return 0;
- X XSetFont (u->dpy, u->gc, u->font->fid);
- X XSetForeground (u->dpy, u->gc, u->v->pixel[HUDPixel]);
- X sprintf (buffer, "a=%.1f", RADtoDEG(c->alpha));
- X x = 730 * u->width / VIEW_WINDOW_WIDTH;
- X y = 130 * u->height / VIEW_WINDOW_HEIGHT;
- X XDrawString (u->dpy, u->win, u->gc, x, y, buffer, strlen(buffer));
- X
- X x1 = 410 * u->width / VIEW_WINDOW_WIDTH;
- X sprintf (buffer, "%4.1f", c->G.z);
- X XDrawString (u->dpy, u->win, u->gc, x1, y, buffer, strlen(buffer));
- X
- X y = 390 * u->height / VIEW_WINDOW_HEIGHT;
- X sprintf (buffer, "%7d", (int)(-c->Cg.z * 60.0));
- X XDrawString (u->dpy, u->win, u->gc, x, y, buffer, strlen(buffer));
- X
- X x = 410 * u->width / VIEW_WINDOW_WIDTH;
- X doCompassScale (u->dpy, u->win, u->gc, &(u->hdgScale), RADtoDEG(c->curHeading)*100.0,
- X u->fth, u->ftw);
- X doScale (u->dpy, u->win, u->gc, &(u->altScale), -c->Sg.z, u->fth, u->ftw);
- X doScale (u->dpy, u->win, u->gc, &(u->velScale), FPStoKTS(mag(c->Cg)),
- X u->fth, u->ftw);
- X
- X sprintf (buffer, "%3d%% %s", (int)((double)c->throttle/327.68),
- X (c->flags & FL_AFTERBURNER) ? "AB" : "");
- X XDrawString (u->dpy, u->win, u->gc, x, y, buffer, strlen(buffer));
- X
- X x = 380 * u->width / VIEW_WINDOW_WIDTH;
- X y = 420 * u->height / VIEW_WINDOW_HEIGHT;
- X
- X doLadder (c, u);
- X
- X for (i=0; i<3; ++i) {
- X XDrawString (u->dpy, u->win, u->gc, x, y, c->leftHUD[i],
- X strlen (c->leftHUD[i]));
- X y += u->fth;
- X }
- X
- X return 0;
- X
- X}
- X
- Xstatic double L_half_width = 90.0;
- Xstatic double L_end = 25.0;
- Xstatic double L_height = 220.0;
- Xstatic double L_major_tick_interval = 10.0;
- Xstatic double L_major_tick_height = 90.0;
- X
- Xint doLadder (c, u)
- Xcraft *c;
- Xviewer *u;{
- X
- X double x = c->curPitch, cx, s;
- X double sinP, cosP, pixelsPerDegree;
- X XSegment seg[24];
- X XRectangle rect[1];
- X int i, rung, windX, windY, w, tx, ty;
- X char buf[16];
- X VPoint tmp;
- X
- X rect[0].x = u->xCenter - 125;
- X rect[0].y = u->yCenter - 110;
- X rect[0].width = 250;
- X rect[0].height = 220;
- X
- X s = ((int)(RADtoDEG(x)) / 10 * 10) - 20;
- X rung = s;
- X
- X pixelsPerDegree = L_major_tick_height / L_major_tick_interval;
- X cx = (RADtoDEG(x) - s) * pixelsPerDegree;
- X sinP = cos(c->curRoll);
- X cosP = sin(c->curRoll);
- X for (i=0; i<5; ++i, cx -= L_major_tick_height, rung +=10) {
- X seg[i*2].x1 = L_half_width * sinP + cx * cosP + u->xCenter;
- X seg[i*2].y1 = -L_half_width * cosP + cx * sinP + u->yCenter;
- X seg[i*2].x2 = L_end * sinP + cx * cosP + u->xCenter;
- X seg[i*2].y2 = -L_end * cosP + cx * sinP + u->yCenter;
- X seg[i*2+1].x1 = -L_end * sinP + cx * cosP + u->xCenter;
- X seg[i*2+1].y1 = L_end * cosP + cx * sinP + u->yCenter;
- X seg[i*2+1].x2 = -L_half_width * sinP + cx * cosP + u->xCenter;
- X seg[i*2+1].y2 = L_half_width * cosP + cx * sinP + u->yCenter;
- X sprintf (buf, "%d", rung);
- X if (seg[i*2].x1 >= rect[0].x && seg[i*2].x1 <
- X rect[0].x+rect[0].width &&
- X seg[i*2].y1 >= rect[0].y && seg[i*2].y1 <
- X rect[0].y+rect[0].height)
- X XDrawString (u->dpy, u->win, u->gc,
- X seg[i*2].x1 + 2, seg[i*2].y1 + 5,
- X buf, strlen(buf));
- X }
- X
- X i = i * 2;
- X
- X XSetClipRectangles (u->dpy, u->gc, 0, 0, rect, 1, YXBanded);
- X
- X windX = (int) (RADtoDEG(c->beta) * pixelsPerDegree) + u->xCenter;
- X windY = (int) (RADtoDEG(c->alpha) * pixelsPerDegree) + u->yCenter;
- X
- X seg[i].x1 = windX - 18;
- X seg[i].y1 = windY;
- X seg[i].x2 = windX - 9;
- X seg[i++].y2 = windY;
- X
- X seg[i].x1 = windX + 18;
- X seg[i].y1 = windY;
- X seg[i].x2 = windX + 9;
- X seg[i++].y2 = windY;
- X
- X seg[i].x1 = windX;
- X seg[i].y1 = windY - 9;
- X seg[i].x2 = windX;
- X seg[i++].y2 = windY - 15;
- X
- X/*
- X * Gether weapon display info (and maybe draw a reticle).
- X */
- X
- X doWeaponDisplay (c, u);
- X
- X/*
- X * Draw a target designator around the current primary radar target.
- X */
- X
- X if (c->curRadarTarget >= 0) {
- X
- X w = DESIGNATOR_SIZE * u->height / VIEW_WINDOW_HEIGHT * 0.5;
- X
- X VTransform (&(ptbl[c->curRadarTarget].Sg),
- X &u->v->eyeSpace, &tmp);
- X
- X/* radar target is assumed to be ahead of us (tmp.z > 0.0) */
- X
- X tx = u->v->Middl.x + tmp.x * u->v->Scale.x / tmp.z;
- X ty = u->v->Middl.y - tmp.y * u->v->Scale.y / tmp.z;
- X
- X seg[i].x1 = tx - w;
- X seg[i].y1 = ty - w;
- X seg[i].x2 = tx + w;
- X seg[i++].y2 = ty - w;
- X
- X seg[i].x1 = tx + w;
- X seg[i].y1 = ty - w;
- X seg[i].x2 = tx + w;
- X seg[i++].y2 = ty + w;
- X
- X seg[i].x1 = tx + w;
- X seg[i].y1 = ty + w;
- X seg[i].x2 = tx - w;
- X seg[i++].y2 = ty + w;
- X
- X seg[i].x1 = tx - w;
- X seg[i].y1 = ty + w;
- X seg[i].x2 = tx - w;
- X seg[i++].y2 = ty - w;
- X }
- X
- X XDrawSegments (u->dpy, u->win, u->gc, seg, i);
- X XDrawArc (u->dpy, u->win, u->gc, u->xCenter-2, u->yCenter-2, 4, 4, 0, 360*64);
- X XDrawArc (u->dpy, u->win, u->gc, windX-8, windY-8, 16, 16, 0, 360*64);
- X
- X XSetClipMask (u->dpy, u->gc, None);
- X
- X return 0;
- X}
- X
- Xint doRPM (c, u)
- Xcraft *c;
- Xviewer *u;{
- X
- X int x, y, x1, y1, len, i;
- X double percent, p;
- X char s[32], s1[32];
- X
- X x = ENG_X * u->width / FS_WINDOW_WIDTH;
- X y = ENG_Y * u->width / FS_WINDOW_WIDTH;
- X len = (eng_x_hot - 6)* u->width / FS_WINDOW_WIDTH;
- X
- X XSetForeground (u->dpy, u->gc, u->v->pixel[whitePixel]);
- X XSetBackground (u->dpy, u->gc, u->v->pixel[blackPixel]);
- X XCopyPlane (u->dpy, u->eng, u->win, u->gc, 0, 0, eng_width,eng_height,
- X x - eng_x_hot, y - eng_y_hot, 1);
- X
- X percent = (double) c->throttle / 32768.0 * 100.0;
- X if (percent < 60.0) {
- X p = (60.0 - percent) / 120.0 * pi;
- X x1 = x + len * cos(p);
- X y1 = y - len * sin(p);
- X }
- X else {
- X p = (percent - 60.0) / 40.0 * pi;
- X x1 = x + len * cos(p);
- X y1 = y + len * sin(p);
- X }
- X
- X XDrawLine (u->dpy, u->win, u->gc, x, y, x1, y1);
- X
- X/*
- X * Print Fuel and Fuel consumption rate
- X */
- X
- X sprintf (s, "%7s lbs Total", ItoA ((int) c->fuel, s1));
- X XDrawImageString (u->dpy, u->win, u->gc, x-30, y+68, s, strlen(s));
- X sprintf (s, "%7s lbs/hour", ItoA ((int) (fuelUsed(c)*3600.0/deltaT), s1));
- X XDrawImageString (u->dpy, u->win, u->gc, x-30, y+68+u->fth, s, strlen(s));
- X
- X/*
- X * Display Flap Setting
- X */
- X
- X if (c->flapSetting > DEGtoRAD(29.0))
- X i=3;
- X else if (c->flapSetting > DEGtoRAD(19.0))
- X i=2;
- X else if (c->flapSetting > DEGtoRAD(9.0))
- X i=1;
- X else
- X i=0;
- X
- X x = FLAP_X * u->width / FS_WINDOW_WIDTH;
- X y = FLAP_Y * u->width / FS_WINDOW_WIDTH;
- X
- X XCopyPlane (u->dpy, u->flap[i], u->win, u->gc, 0, 0, flaps0_width,
- X flaps0_height, x, y, 1);
- X sprintf (s, "Flaps: %d", (int) RADtoDEG(c->curFlap));
- X XDrawImageString (u->dpy, u->win, u->gc, x+flaps0_x_hot, y+flaps0_y_hot,
- X s, strlen(s));
- X
- X return 0;
- X}
- *-*-END-of-./fsim/doViews.c-*-*
- --
- Riley Rainey Internet: riley@mips.com
- MIPS Computer Systems Phone: +1 214 770-7979
- Dallas, Texas
-
- dan
- ----------------------------------------------------
- O'Reilly && Associates argv@sun.com / argv@ora.com
- Opinions expressed reflect those of the author only.
-